import 'package:flutter_base_app/generated/json/base/json_convert_content.dart';
import 'package:flutter_base_app/model/login_data.dart';
import 'package:flutter_base_app/utils/user/user_data.dart';


LoginData $LoginDataFromJson(Map<String, dynamic> json) {
  final LoginData loginData = LoginData();
  final Token? token = jsonConvert.convert<Token>(json['token']);
  if (token != null) {
    loginData.token = token;
  }
  final UserData? userInfo = jsonConvert.convert<UserData>(json['userInfo']);
  if (userInfo != null) {
    loginData.userInfo = userInfo;
  }
  return loginData;
}

Map<String, dynamic> $LoginDataToJson(LoginData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['token'] = entity.token.toJson();
  data['userInfo'] = entity.userInfo.toJson();
  return data;
}

extension LoginDataExtension on LoginData {
  LoginData copyWith({
    Token? token,
    UserData? userInfo,
  }) {
    return LoginData()
      ..token = token ?? this.token
      ..userInfo = userInfo ?? this.userInfo;
  }
}

Token $TokenFromJson(Map<String, dynamic> json) {
  final Token token = Token();
  final String? accessToken = jsonConvert.convert<String>(json['accessToken']);
  if (accessToken != null) {
    token.accessToken = accessToken;
  }
  final String? refreshToken = jsonConvert.convert<String>(json['refreshToken']);
  if (refreshToken != null) {
    token.refreshToken = refreshToken;
  }
  return token;
}

Map<String, dynamic> $TokenToJson(Token entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['accessToken'] = entity.accessToken;
  data['refreshToken'] = entity.refreshToken;
  return data;
}

extension TokenExtension on Token {
  Token copyWith({
    String? accessToken,
    String? refreshToken,
  }) {
    return Token()
      ..accessToken = accessToken ?? this.accessToken
      ..refreshToken = refreshToken ?? this.refreshToken;
  }
}